﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        var myApp = (function () {
            var id = 0;
            return {
                next: function () {
                    return id++;
                },

                reset: function () {
                    id = 0;
                }
            };
        })();

        window.console && console.log(
            myApp.next(),
            myApp.next(),
            myApp.reset(),
            myApp.next()
        ) //0, 1, undefined, 0  
    </script>
</head>
<body>
    
</body>
</html>
